package com.ctjsoft.fileupload.mapper;

import com.ctjsoft.fileupload.entity.TFile;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TFileMapper {

    @Select("<script>select * from t_file</script>")
    List<TFile> getFileList();

    @Insert("<script>insert into t_file (id,file_name,bucket_id,upload_time" +
            "<if test=\"isEncryption!=null and isEncryption!=''\">,is_encryption</if>" +
            "<if test=\"key != null and key!=''\">,key</if>" +
            "<if test=\"fileType!=null and fileType!=''\">,file_type</if>" +
            "<if test=\"contentType !=null and contentType!=''\">,content_type</if>" +
            ")values(#{id},#{fileName},#{bucketId},#{uploadTime}" +
            "<if test=\"isEncryption!=null and isEncryption!=''\">,#{isEncryption}</if>" +
            "<if test=\"key != null and key!=''\">,#{key}</if>" +
            "<if test=\"fileType!=null and fileType!=''\">,#{fileType}</if>" +
            "<if test=\"contentType !=null and contentType!=''\">,#{contentType}</if>" +
            ")</script>")
    int addFile(TFile tFile);
}
